﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.businesslogic;
using umbraco.cms.businesslogic.web;
using umbraco.NodeFactory;
using System.Data.SqlClient;

public partial class usercontrols_TeamViewControl_EmailContentControl : System.Web.UI.UserControl
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        Document document = new Document(Node.GetCurrent().Id);
        GetRourceAndDisplay(document);
    }
    protected void GetRourceAndDisplay(Document document)
    {
        string connString = System.Configuration.ConfigurationManager.ConnectionStrings["bug_Db"].ConnectionString;
        string sql = "SELECT Name, Email, Telephone, Question, MSN, Time FROM Email WHERE Email= '" + document.Text + "'";
        using (SqlConnection conn = new SqlConnection(connString))
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                NameLabel.Text = reader[0].ToString();
                EmailLabel.Text = reader[1].ToString();
                TelephoneLabel.Text = reader[2].ToString();
                QuestionBox.Text = reader[3].ToString();
                MsnLabel.Text = reader[4].ToString();
                TimeLabel.Text = reader[5].ToString();
            }
        }
    }
}